#coding: utf-8
class CulturalHeritage::Topic < ActiveRecord::Base
  default_scope where("deleted = 0")
  validates :name, :presence => {:message => "El nombre es requerido"}
  has_many :list_cultural_heritage, :class_name => 'CulturalHeritage::CulturalHeritage',  :foreign_key => 'topic'

  def erasable
    cultuheri = CulturalHeritage::CulturalHeritage.count_topic_dependencies(id)
    if cultuheri >0
      return "Imposible borrar. Existen dependencias en patrimonio cultural/preregistro"          
    end
    return nil
  end
end
